from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from .api import cep, cef, ceq, query
from .core.database import engine, Base

# 创建数据库表
Base.metadata.create_all(bind=engine)

app = FastAPI()

# 添加CORS中间件
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 注册路由
app.include_router(cep.router, prefix="/api", tags=["transactions"])
app.include_router(cef.router, prefix="/api", tags=["transactions"])
app.include_router(ceq.router, prefix="/api", tags=["transactions"])
app.include_router(query.router, prefix="/api", tags=["transactions"])

@app.get("/")
async def root():
    return {"message": "卡系统交易测试平台API服务"} 